<?php

namespace app\modules\admin\forms\advert;

use app\common\forms\BaseForm;

class AdvertForm extends BaseForm{

    public $advert_id;
    public $advert_desc;
    public $banner;
    public $uri;
    public $direct_type;
    public $sort;
    public $place;
    public $is_show;

    public function scenarios()
    {
        return [
            'create'=>[
                'advert_desc','banner','uri','direct_type','sort','place','is_show',
            ],
            'update'=>[
                'advert_desc','advert_id','banner','uri','direct_type','sort','place','is_show',
            ],
        ];
    }

    public function rules()
    {
        return [
            ['advert_id','required','on'=>['update'],'message'=>\Yii::t("app","ID不能为空")],
            ['advert_desc','required','on'=>['create','update'],'message'=>\Yii::t("app","描述不能为空")],
            ['banner','required','on'=>['create','update'],'message'=>\Yii::t("app","横幅不能为空")],
            ['direct_type','required','on'=>['create','update'],'message'=>\Yii::t("app","跳转类型不能为空")],
            ['place','required','on'=>['create','update'],'message'=>\Yii::t("app","地址码不能为空")],
            ['sort','integer','skipOnEmpty'=>false,'on'=>['create','update'],'message'=>\Yii::t("app","排序错误")],
            ['is_show','in','range'=>[1,2],'on'=>['create','update'],'skipOnEmpty'=>false,'message'=>\Yii::t("app","显示值错误")],
            ['uri','safe','on'=>['create','update']]
        ];
    }
}